<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Kalamazoo Animal Rescue - Delete - Event Pet Schedule</TITLE>

<META NAME="Author" CONTENT="Cayce Wilcox-York - York Systems Group">
<META HTTP-EQUIV="Expires" CONTENT="Tuesday, 26 March 2002 08:00:00 GMT">

</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#800000">
<H2>Delete Pet from Event Schedule</H2>
<BR CLEAR=ALL>
<BR>
If you came to this page using your BACK button (for instance, if you are here to delete another pet), hit reload/refresh to update the list of pets displayed.<BR><BR>

You can only select one pet to delete each time.<BR><BR>
<form name="f" action="delsched_it2.php" method="POST">
<?php


include($_SERVER['DOCUMENT_ROOT'] ."/includes/db.php");

				// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect

// Join data from four tables so as to get name of pets, foster, event & appointment.
// Had problems trying to set date >= $today which equaled date("Y-m-d")
//  mySQL function now() seems to working great.

if ($by_date):
	$result = @mysql_query("SELECT * FROM events, eventPets, cats, dogs, volunteers
				WHERE (eventPets.tagNum=cats.tagNum 
				OR eventPets.tagNum=dogs.tagNum)
				AND
				eventPets.eventID=events.eventID AND
				(cats.volunteer_id=volunteers.volunteer_id
				OR dogs.volunteer_id=volunteers.volunteer_id) AND
				(cats.pet_status = 'v' OR dogs.pet_status = 'v')
				AND
				events.eventDate >= now()
				ORDER BY events.eventDate, volunteers.name ASC");
	else:
	$result = @mysql_query("SELECT * FROM events, eventPets, cats, dogs, volunteers
				WHERE (eventPets.tagNum=cats.tagNum 
				OR eventPets.tagNum=dogs.tagNum)
				AND
				eventPets.eventID=events.eventID AND
				(cats.volunteer_id=volunteers.volunteer_id
				OR dogs.volunteer_id=volunteers.volunteer_id) AND
				(cats.pet_status = 'v' OR dogs.pet_status = 'v')
				AND
				events.eventDate >= now()
				ORDER BY volunteers.name, events.eventDate ASC");
	endif;
if (!$result) {
  echo("<p>Error performing query: " . mysql_error() . "</p>");
  exit();
}  // end if

echo("<CENTER><TABLE cellpadding=3>");
echo("<TR><TH><B>Delete</B></TH>");
echo("<TH><B>Pet Name</B></TH>");
echo("<TH><B>Foster Home</B></TH>");
echo("<TH><B>Date</B></TH>");
echo("<TH><B>Time</B></TH>");
echo("<TH><B>Event</B></TH></TR>");
$shade = 1;

while ( $row = mysql_fetch_array($result) )  {			// while there is data
   $id = $row["tagNum"];
   $name =  $row["pet_name"];
   $eventName = $row["eventName"];
   $foster_home = $row["name"];
   $date = $row["eventDate"];
   	list($year, $month, $day) = explode("-", $date);
	$showDate = date("l, F j, Y", mktime(0,0,0,$month, $day,$year));
   $a_time = $row["arrive_time"];
   $b_time = $row["depart_time"];
if ($shade) {
	$clr = "#ffcccc";
	$shade=0;
	} else {
	$clr = "#ccffcc";
	$shade=1; 
	}

	echo("<TR bgcolor=".$clr."><TD><CENTER>");
	//  Combine id and date to pass as the key 
	echo("<INPUT TYPE=\"RADIO\" NAME=\"delPet\" VALUE=\"".$id."-".$date."\">");
	echo("</CENTER></TD>");
	echo ("<TD>". $name."</TD>");
	echo ("<TD>". $foster_home."</TD>");
	echo ("<TD>". $showDate."</TD>");
	echo ("<TD>". $a_time. " - " . $b_time . "</TD>");
	echo ("<TD>". $eventName . "</TD></TR>");
}  // end while

echo("</TABLE></CENTER>");

?>
<BR>
<input type=submit value="Delete From Schedule">&nbsp;&nbsp;&nbsp;
<input type=reset value="Reset">

</FORM>
<BR><BR>
Return to <a href="sched_admin.php">Admin Page</a> without Deleting<BR>


</BODY>
</HTML>
